<template>
  <div class="container-bg">
    <el-row :gutter="15">
      <el-col :span="24">
        <el-table :data="tableData" stripe style="width: 100%">
          <el-table-column prop="comment" label="抓拍类型"> </el-table-column>
          <el-table-column prop="switch" label="是否启用">
            <template slot-scope="scope">
              <!-- {{ scope.row.switch }} -->
              <el-switch
                v-model="scope.row.switch"
                active-value="1"
                inactive-value="0"
              />
            </template>
          </el-table-column>
          <el-table-column prop="format" label="图片类型">
            <template slot-scope="scope">
              <el-radio-group v-model="scope.row.format">
                <el-radio label="jpg">jpg</el-radio>
                <el-radio label="bmp" v-if="false">bmp</el-radio>
                <el-radio label="png" v-if="false">png</el-radio>
              </el-radio-group>
            </template>
          </el-table-column>
        </el-table>
      </el-col>
      <el-col class="mt-20" :span="13" v-if="isAdmin">
        <el-button type="primary" @click="onSubmit">保存</el-button>
        <!-- <el-button @click="getSnapshotConfig">取消</el-button> -->
      </el-col>
    </el-row>
  </div>
</template>

<script>
import {
  getSnapshotConfigApi,
  editSnapshotConfigApi,
} from "@/api/access/equipment.js";
import Cookies from 'js-cookie'
export default {
  name: "MvCloudgateTerminalCameraConfig",
  data() {
    return {
      isAdmin:false,
      tableData: [],
    };
  },
  created() {
    this.isAdmin=Cookies.get('roleId')*1>0?false:true
    this.getSnapshotConfig();
  },
  mounted() {},

  methods: {
    onSubmit() {
      editSnapshotConfigApi(this.tableData).then((res) => {
        this.tableData = res;
        this.$message.success("保存成功");
      });
    },
    getSnapshotConfig() {
      getSnapshotConfigApi().then((res) => {
        // console.log(res);
        this.tableData = res;
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.mt-20 {
  margin-top: 20px;
}
</style>
